package cn.com.tarotframework.server.exception.service.impl;

import cn.com.tarotframework.server.exception.po.Students;
import cn.com.tarotframework.server.exception.service.ExceptionService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.Optional;


/**
 * copyright (C), 2022, 塔罗牌基础架构
 *
 * @program: tarot-demo
 * @author: xincan
 * @date: 2022/12/22 17:35
 * @version: 0.0.1-SNAPSHOT
 * @description: //TODO
 */
@Service
public class ExceptionServiceImpl implements ExceptionService {

    @Override
    public void getException(int id) {

//        抱500，系统异常，应为Assert内部抛出IllegalStateException异常
//        throw new IllegalArgumentException("抛出 常规异常 IllegalArgumentException");

        throw new IllegalArgumentException();

//        抱500，系统异常，系统默认断言，应为Assert内部抛出IllegalStateException异常
//        Assert.hasText(null, "Assert 字符串不能为空");

//        抛出3000,业务异常，自定义断言，应为TarotAssert内部抛出TarotBusinessException自自定义顶级异常
//        TarotAssert.hasText(null, "自定义断言");

//        抛出3000,业务异常，应为TarotBusinessException自定义顶级异常
//        throw new TarotBusinessException("抛出 TarotBusinessException");

//        抛出3000,业务异常，应为DemoException继承TarotBusinessException自定义顶级异常
//        throw new DemoException("抛出 DemoException");

//        抛出3000,业务异常，应为TarotAssert内部抛出TarotBusinessException自定义顶级异常
//        Optional<Students> students = Optional.empty();
//        TarotAssert.isNull(students, "学生对象不能为空");


//        抛出3000,业务异常，应为TarotBusinessException自定义顶级异常
//        Optional<Students> os1 = Optional.ofNullable(null);
//        os1.orElseThrow(() -> new TarotBusinessException("orElseThrow 学生"));



    }

    @Override
    public Students getStudent(String id) {

        return Students.builder().id(id).name("里斯").build();

    }


}
